package cn.powerone.scm.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.powerone.common.annotation.Log;
import cn.powerone.common.core.controller.BaseController;
import cn.powerone.common.core.domain.AjaxResult;
import cn.powerone.common.enums.BusinessType;
import cn.powerone.scm.domain.ScmStatsMonthly;
import cn.powerone.scm.service.IScmStatsMonthlyService;
import cn.powerone.common.utils.poi.ExcelUtil;
import cn.powerone.common.core.page.TableDataInfo;

/**
 * 月度统计信息-总Controller
 * 
 * @author PowerOne
 * @date 2025-09-09
 */
@RestController
@RequestMapping("/scm/scmStatsMonthly")
public class ScmStatsMonthlyController extends BaseController
{
    @Autowired
    private IScmStatsMonthlyService scmStatsMonthlyService;

    /**
     * 查询月度统计信息-总列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsMonthly:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScmStatsMonthly scmStatsMonthly)
    {
        startPage();
        List<ScmStatsMonthly> list = scmStatsMonthlyService.selectScmStatsMonthlyList(scmStatsMonthly);
        return getDataTable(list);
    }

    /**
     * 导出月度统计信息-总列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsMonthly:export')")
    @Log(title = "月度统计信息-总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScmStatsMonthly scmStatsMonthly)
    {
        List<ScmStatsMonthly> list = scmStatsMonthlyService.selectScmStatsMonthlyList(scmStatsMonthly);
        ExcelUtil<ScmStatsMonthly> util = new ExcelUtil<ScmStatsMonthly>(ScmStatsMonthly.class);
        util.exportExcel(response, list, "月度统计信息-总数据");
    }

    /**
     * 获取月度统计信息-总详细信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsMonthly:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scmStatsMonthlyService.selectScmStatsMonthlyById(id));
    }

    /**
     * 新增月度统计信息-总
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsMonthly:add')")
    @Log(title = "月度统计信息-总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScmStatsMonthly scmStatsMonthly)
    {
        return toAjax(scmStatsMonthlyService.insertScmStatsMonthly(scmStatsMonthly));
    }

    /**
     * 修改月度统计信息-总
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsMonthly:edit')")
    @Log(title = "月度统计信息-总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScmStatsMonthly scmStatsMonthly)
    {
        return toAjax(scmStatsMonthlyService.updateScmStatsMonthly(scmStatsMonthly));
    }

    /**
     * 删除月度统计信息-总
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsMonthly:remove')")
    @Log(title = "月度统计信息-总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scmStatsMonthlyService.deleteScmStatsMonthlyByIds(ids));
    }
}
